from PyOEUO.game import Game
import sys,time

g=Game()  # Create a Game object taht represents our interface to the game

# Check that we are told which client to use (or it's the only one)
# CliCnt is a variable in game.dll that counts the number of active clients
# Variables can be accesed with g.VarName

try:
    myclient=int(sys.argv[1])
except:
    myclient=0

if g.CliCnt==0:
    print 'No running UO clients detected.'
    sys.exit(-1)
elif g.CliCnt>1 and (myclient<1 or myclient>g.CliCnt):
    print 'Multiple running UO clients detected.'
    print 'Please select one and run "%s <clinr>"'%sys.argv[0]
    for x in xrange(1,g.CliCnt+1):
        g.CliNr=x
        if g.CliLogged:
            print '%d) %s - %s (%s)'%(x,g.CharName,g.Shard,g.CliVer)
        else:
            print '%d) Not logged in (%s)'%(x,g.CliVer)
    sys.exit(-1)
elif g.CliCnt==1:
    myclient=1

g.CliNr=myclient # Select client
print 'Selected client: %s - %s (%s)'%(g.CharName,g.Shard,g.CliVer)

g.TargCurs=True
while g.TargCurs:
    time.sleep(0.1)

i=g.Item(g.LTargetID)
for k,v in i.__dict__.items():
    print '%s: %s'%(k,v)
